package com.erp.erp_servers.warehouse.imp;

import com.erp.erp_dao.warehouse.IInventoryDetailDao;
import com.erp.erp_entitys.warehouse.entity.InventoryDetailEntity;
import com.erp.erp_servers.warehouse.IInventoryDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName : InventoryDetailServiceImp
 * @Description : 盘点明细实现类
 * @Author : lst
 * @Date: 2020-07-24 14:52
 */
@Service
public class InventoryDetailServiceImp implements IInventoryDetailService {

    /**
     * 盘点明细接口
     */
    private final IInventoryDetailDao inventoryDetailDao;

    @Autowired
    public InventoryDetailServiceImp(IInventoryDetailDao inventoryDetailDao) {
        this.inventoryDetailDao = inventoryDetailDao;
    }

    /**
     * 通过实体作为筛选条件查询
     * @param inventoryDetail 实例对象
     * @return 对象列表
     */
    @Override
    public List<InventoryDetailEntity> queryAll(InventoryDetailEntity inventoryDetail) {
        return inventoryDetailDao.queryAll(inventoryDetail);
    }

    /**
     * 新增数据
     * @param inventoryDetail 实例对象
     * @return 影响行数
     */
    @Override
    public int insert(InventoryDetailEntity inventoryDetail) {
        return inventoryDetailDao.insert(inventoryDetail);
    }


    /**
     * 通过主键修改数据
     * @param inventoryDetail 主键对象
     * @return 影响行数
     */
    @Override
    public int update(InventoryDetailEntity inventoryDetail) {
        return inventoryDetailDao.update(inventoryDetail);
    }

    /**
     * 盘点详情批量新增
     * @param list 盘点详情对象集合
     * @return 影响行数
     */
    @Override
    public int insertInventoryDetailList(List<InventoryDetailEntity> list) {
        if(list.isEmpty()){
            return 0;
        }
        return inventoryDetailDao.insertInventoryDetailList(list);
    }
}
